package com.quanyan.common.utils;

import com.quanyan.common.http.HttpClientUtils;

import java.net.URLEncoder;

/**
 * Created by Kingson.chan on 2016/8/19 0019.
 */
public class ShortUrlUtils {
    public static String getShortUrl(String shareUrl){
        String url = "http://api.t.sina.com.cn/short_url/shorten.json?source=3271760578&url_long=";
        String httpresult = "";
        try {
            shareUrl = URLEncoder.encode(shareUrl, "UTF-8");
            httpresult = HttpClientUtils.get(url + shareUrl);
            return httpresult;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        String str = ShortUrlUtils.getShortUrl("http://www.baidu.com");
        System.out.println(str);
    }

}
